#include "BuffEffectInterface.h"

BuffEffectInterface::BuffEffectInterface()
{

}

BuffEffectInterface::~BuffEffectInterface()
{

}

bool BuffEffectInterface::sendEffectToCreature(Creature* pSender, Creature* pRecv, uint32_t skillId, uint32_t buffBagId, uint32_t stateBagRate, uint32_t stateBagTime, const std::string& param)
{
	if (!pSender || !pRecv)
	{
		return false;
	}

	if (pSender->CreatureKind() != CREATURE_PLAYER && pSender->CreatureKind() != CREATURE_MONSTER)
	{
		return false;
	}

	if (pRecv->CreatureKind() != CREATURE_PLAYER || pRecv->CreatureKind() != CREATURE_MONSTER)
	{
		return false;
	}

	if (pRecv->IsDead())
	{
		return false;
	}

	//bool ret = pRecv->GetBuffBag()->BuffEffect_RegisterEffect(pSender, skillId, buffBagId, stateBagRate, stateBagTime, param);
	//if (ret == false)
	//{
	//	//消息发送,状态包被免疫或没有叠加上
	//}
	return true;
}

Creature* BuffEffectInterface::GetBuffSender(BuffBagEffectInfo* pBuffBag, Creature* pRecv)
{
	if (!pBuffBag || !pRecv)
	{
		return nullptr;
	}

	CharIDType senderCid = pBuffBag->m_senderId;

	return GetBuffSender(senderCid, pRecv);
}

Creature* BuffEffectInterface::GetBuffSender(CharIDType senderCid, Creature* pRecv)
{
	if (!pRecv)
	{
		return nullptr;
	}

	Scene* pScene = pRecv->GetScene();
	if (!pScene)
	{
		return nullptr;
	}

	return pScene->GetCreature(senderCid);
}
